import time
from selenium import webdriver
from selenium.webdriver.common.by import By


class TestCase:
    def __init__(self):
        self.driver = webdriver.Chrome()
        self.driver.get('https://www.baidu.com')

    def clear(self):
        # clear()清空内容
        kw = self.driver.find_element(By.ID, 'kw')
        kw.send_keys('天气预报')
        # 清空
        time.sleep(2)
        kw.clear()
        # 输入
        kw.send_keys('腾讯')

    def get_attribute(self):
        # get_attribute()获得属性值
        kw = self.driver.find_element(By.ID, 'kw')
        print(kw.get_attribute('outerHTML'))
        print(kw.get_attribute('id'))

    def is_displayed(self):
        # is_displayed()判断元素是否可见
        kw = self.driver.find_element(By.ID, 'kw')
        print(kw.is_displayed())

    def is_enabled(self):
        # is_enabled()判断元素是否可用
        kw = self.driver.find_element(By.ID, 'kw')
        print(kw.is_enabled())

    def quit(self):
        self.driver.quit()


if __name__ == '__main__':
    case = TestCase()
    # case.clear()
    # case.get_attribute()
    # case.is_displayed()
    case.is_enabled()
    case.quit()




